import { Controller, Get, Post, Body, Patch, Param, Delete, ValidationPipe } from '@nestjs/common';
import { WebLinkService } from './web-link.service';
import { WebClassifyDto } from './dto/web-classify';
import { Public } from 'src/utils/public';
import { WebLinkDto } from './dto/web-link.dto';


@Controller('web')
export class WebLinkController {
  constructor(private readonly webLinkService: WebLinkService) {}

  //新增分类
  @Post('classify/add')
  create(@Body(ValidationPipe) webClassifyDto:WebClassifyDto ) {
    return this.webLinkService.createClassify(webClassifyDto);
  }
  //获取列表
  @Get('classify/list')
  @Public()
  getClassifyList() {
    return this.webLinkService.getClassifyList();
  }
  //修改
  @Post('classify/update')
  update(@Body() webClassifyDto:WebClassifyDto ) {
    return this.webLinkService.updateClassify(webClassifyDto);
  }
  //删除
  @Delete('classify/:id')
  deleteClassify(@Param('id') id: number) {
    return this.webLinkService.deleteClassify(id);
  }
  
  //新增链接
  @Post('link/add')
  createLink(@Body(ValidationPipe) webLinkDto:WebLinkDto ) {
    return this.webLinkService.createLink(webLinkDto);
  }
  //获取列表
  @Get('link/list')
  @Public()
  getListList() {
    return this.webLinkService.getLinkList();
  }
  //修改
  @Post('link/update')
  updateLink(@Body() webClassifyDto:WebClassifyDto ) {
    return this.webLinkService.updateLink(webClassifyDto);
  }
  //删除
  @Delete('link/:id')
  deleteLink(@Param('id') id: number) {
    return this.webLinkService.deleteLink(id);
  }
}
